<%--
  Created by IntelliJ IDEA.
  User: dqf
  Date: 2015/3/2
  Time: 16:18
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>

<div class="row">
    <!-- NEW WIDGET START -->
    <article class="col-sm-12 col-md-12 col-lg-12">
        <div class="jarviswidget well" id="wid-id-3"
             data-widget-colorbutton="false"
             data-widget-editbutton="false"
             data-widget-togglebutton="false"
             data-widget-deletebutton="false"
             data-widget-fullscreenbutton="false"
             data-widget-custombutton="false"
             data-widget-sortable="false">
            <!-- widget div-->
            <div>
                <div class="widget-body">
                    <a class="btn btn-default" id="btn-re-common" href="javascript:void(0)">
                        <i class="fa fa-lg fa-mail-reply-all"></i>项目信息
                    </a>
                    <a class="btn btn-default pull-right pull-right-fix" id="btn-save-common" href="javascript:void(0);"><i class="fa fa-lg fa-download"></i> 保存</a>
                    <hr class="simple">

                    <form id="proSignIn" class="smart-form" novalidate="novalidate" action="" method="post">
                        <input type="hidden" name="keyId" id="keyId" value="<s:property value="proSignIn.id" />"/>

                        <header id="title" style="display: block;">
                            考勤签到表
                        </header>
                        <fieldset>
                            <div class="row">
                                <label class="label col col-2">
                                    <i class="fa fa-asterisk txt-color-red"></i>
                                    <a  href="javascript:void(0);" key="btn-choose-proInfo"> 项目名称</a>
                                </label>
                                <section class="col col-5">
                                    <label class="input state-disabled">
                                        <input disabled type="text" id="proInfoName"
                                               value="<s:property value="proSignIn.proInfo.name"/>"/>
                                        <input type="hidden" id="proInfoId" name="proInfoId"
                                               value="<s:property value="proSignIn.proInfo.id"/>"/>
                                    </label>
                                </section>
                            </div>
                            <div class="row">
                                <label class="label col col-2">
                                    所在地区
                                </label>
                                <section class="col col-5">
                                    <label class="input state-disabled">
                                        <input disabled type="text" id="proArea"
                                               value="<s:property value="proArea"/>"/>
                                    </label>
                                </section>
                            </div>
                            <div class="row">
                                <label class="label col col-2">
                                    项目地址
                                </label>
                                <section class="col col-2">
                                    <label class="input state-disabled">
                                        <input disabled type="text" id="proAddress"
                                               value="<s:property value="proSignIn.proInfo.address"/>"/>
                                    </label>
                                </section>
                            </div>
                            <div class="row">
                                <label class="label col col-2">
                                    签到时间
                                </label>
                                <section class="col col-2">
                                    <label class="input state-disabled">
                                        <i class="icon-append fa fa-calendar"></i>
                                        <input disabled class="hasDatepicker form-control" name="createDate" id="createDate"
                                               type="text" value="<s:date name="proSignIn.createDate" format="yyyy-MM-dd hh:mm"/>">
                                    </label>
                                </section>
                            </div>
                            <div class="row">
                                <label class="label col col-2">
                                    签到人
                                </label>
                                <section class="col col-2">
                                    <label class="input state-disabled">
                                        <input type="text" name="creater" id="creater" value="<s:property value="proSignIn.creater.name"/>" disabled>
                                    </label>
                                </section>
                            </div>
                            <div class="row">
                                <label class="label col col-2">
                                    签到地址
                                </label>
                                <section class="col col-5">
                                    <label class="input">
                                        <input name="address" id="address" placeholder="请输入签到地址"
                                               type="text" value="<s:property value="proSignIn.address"/>">
                                    </label>
                                </section>
                            </div>
                            <div class="row">
                                <label class="label col col-2">
                                    <i class="fa fa-asterisk txt-color-red"></i>
                                    考勤状态
                                </label>
                                <section class="col col-5">
                                    <div class="inline-group">
                                        <label class="radio">
                                            <input type="radio" id="statusY" name="status" value="1" <s:property value="proSignIn.status==1?'checked':''"/>>
                                            <i></i>正常</label>
                                        <label class="radio">
                                            <input type="radio" id="statusN" name="status" value="0" <s:property value="proSignIn.status==0?'checked':''"/>>
                                            <i></i>迟到</label>
                                    </div>
                                </section>
                            </div>

                        </fieldset>
                    </form>
                </div>
            </div>
        </div>
    </article>
</div>

<script>
    //选择项目对话框
    $("a[key='btn-choose-proInfo']").unbind("click").bind("click",function(){
        ajax_action("ajax-dialog!proInfoDlg.action",{keyIds:$("div.widget-body #proInfoId").val()},{},function(pdata){
            oDialog.open({
                title:"请选择项目",
                data:pdata.data.data,
                callback:function(){
                    var obj =$("#group input:checked");
                    var name = getArrProp(obj,"key");
                    var id = getArrProp(obj,"id");
                    $("div.widget-body #proInfoName").val(name);
                    $("div.widget-body #proInfoId").val(id);
                }
            });
        });
    });

    //返回视图
    $("#btn-re-common").click(function(){
        loadURL("ajax-project!view.action",$('div#main div#business_data'));
    });
    //校验
    $("#proSignIn").validate({
        rules : {
            proInfoId : {
                required : true
            },
            address:{
                required : true
            }
        },
        messages : {
            proInfoId : {
                required : '请选择项目'
            },
            address:{
                required : '请输入签到地址'
            }
        },
        ignore: "",
        errorPlacement : function(error, element) {
            error.insertAfter(element.parent());
        }
    });

    $('.hasDatepicker').datetimepicker({
        format: 'yyyy-mm-dd',
        weekStart: 1,
        autoclose: true,
        todayBtn: 'linked',
        language: 'zh-CN',
        minView:2
    });
    //保存
    $("#btn-save-common").click(
            function(e) {
                $.SmartMessageBox({
                    title : "提示：",
                    content : "确定提交吗？",
                    buttons : '[取消][确认]'
                }, function(ButtonPressed) {
                    if (ButtonPressed === "取消") {
                        e.preventDefault();
                        e.stopPropagation();
                        return;
                    }
                    if (ButtonPressed === "确认") {
                        var $valid = $("#proSignIn").valid();
                        if(!$valid){
                            return false;
                        }

                        if($("input:checked").size()==0){
                            alert("请选择考勤状态！");
                            return false;
                        }

                        $("#btn-save-common").attr("disabled", "disabled");
                        form_save("proSignIn","<%=path%>/com/ajax-pro-signin!save.action");
                        loadURL("ajax-pro-back!view.action",$('div#main div#business_data'));
                    }
                });
            }
    );

</script>
<script type="text/javascript">

    $(function(){

    });

</script>
